Skip to content

Forward Wayland modifier events to wlroots seat when nested - #2273

Open
bjornmp wants to merge 1 commit into
ValveSoftware:masterfrom
bjornmp:fix/wayland-nested-modifier-forwarding
Open

bjornmp wants to merge 1 commit into
ValveSoftware:masterfrom
bjornmp:fix/wayland-nested-modifier-forwarding

Conversation

@bjornmp

@bjornmp bjornmp commented Jul 21, 2026

Copy link
Copy Markdown

Summary

When gamescope runs nested on a Wayland compositor, it receives wl_keyboard.modifiers from the host compositor but previously only stored them locally. Key events were injected via a stub virtual keyboard with no modifier state, so clients (especially Xwayland apps) received key presses with modifier state 0x0.

This change forwards modifier events to the wlroots keyboard_group and injects keys through that keyboard, so the seat reports correct Shift/Ctrl/Alt state.

Fixes #1740
Fixes #2032

Root cause

Discussed in #1740: older Xwayland versions ran their own XKB state machine and masked this bug. Xwayland 24.1.5+ correctly expects the compositor to forward modifier state (xserver MR 1758), which exposed the issue in gamescope.

Test plan

  • gamescope -- konsole — Shift+letters produce capitals
  • War Thunder via gamescope on KDE Plasma Wayland (Xwayland 24.1.13) — Shift works for typing and game binds
  • Modifier forwarding works regardless of Xwayland version (correct compositor behavior)

Environment

  • openSUSE Tumbleweed, KDE Plasma 6.7 Wayland
  • Xwayland 24.1.13
  • gamescope built from master (976f7fc) with this patch

Made with Cursor

@bjornmp
bjornmp force-pushed the fix/wayland-nested-modifier-forwarding branch 3 times, most recently from 8f9e787 to 8d7e59d Compare July 21, 2026 00:41
When running nested on a Wayland compositor, gamescope received
wl_keyboard.modifiers from the host but only stored them locally.
Key events were injected through a virtual keyboard with no modifier
state, so Xwayland clients saw key presses with state 0x0.

Forward modifier updates to the keyboard group and inject keys through
that keyboard so the seat reports correct Shift/Ctrl/Alt state.

Fixes ValveSoftware#1740
Fixes ValveSoftware#2032

Co-authored-by: Cursor <cursoragent@cursor.com>
@bjornmp
bjornmp force-pushed the fix/wayland-nested-modifier-forwarding branch from 8d7e59d to 405816d Compare September 16, 2026 23:39
@bjornmp

bjornmp commented Sep 16, 2026

Copy link
Copy Markdown
Author

Rebased this onto the latest master to resolve the conflicts. I also rebuilt and tested it locally, and modifier forwarding is still working as expected.

@matte-schwartz

Copy link
Copy Markdown
Collaborator

sorry, there are quite a few issues with this approach. forward modifiers get wiped on any focus change inside of gamescope, modifiers are never cleared when focus leaves, and the null guard is wrong.

I'm working on a branch that'll include forwarding modifiers in a way I'm more comfortable with merging. I'll give you a suggested-by and cc you on it when it's up

@bjornmp

bjornmp commented Sep 29, 2026

Copy link
Copy Markdown
Author

That's fine. This probably needs to be part of a larger wayland input refactor anyway. This was mostly a quick fix I've been using for my immediate need as there was no forwarding at all up to this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shift key combinations and Caps Lock not working inside Gamescope (Wayland + KDE, openSUSE) Unable to type uppercase letters in Wayland clients

2 participants